<style>
    body {
        padding: 15px
    }

    body .layui-form {
        margin: 0
    }

    body .layui-form .layui-form-item {
        margin-bottom: 10px
    }

    body .layui-form fieldset.layui-elem-field {
        margin: 0 0 10px 0
    }
</style>
<script>
    // 数据表格
    layui.use(['table', 'form', 'laydate', 'util'], function () {
        var table = layui.table,
            form = layui.form,
            laydate = layui.laydate,
            util = layui.util,
            $ = layui.jquery;

        var site_url = '//{$smarty.server.SERVER_NAME}' + (('{$smarty.server.SERVER_PORT}' == '80' || '{$smarty.server.SERVER_PORT}' == '443') ? '' : ':{$smarty.server.SERVER_PORT}');
        var path_info = '{$smarty.server.REQUEST_URI|modifier:htmlentities}'.split('?')[0].split('/');
        var area_width = function () {
            return Math.max($(window).width() * 0.809, Math.min($(window).width() - 20, Math.max($(window).width() * 0.618, 480)));
        };
        var area_height = function () {
            return Math.min($(window).height() - 20, Math.max($(window).height() * 0.809, 450));
        };

        //获取应用、控制器和方法
        var lang = path_info[1],
            module = path_info[2].toLocaleLowerCase(),
            controller = path_info[3].toLocaleLowerCase(),
            action = path_info[4].split('.')[0].toLocaleLowerCase();

        // 递归语言文本国际化替换
        var zh_i18n = function (obj, i18nObj) {
            var o = obj.childNodes;
            for (var i = 0; i < o.length; i++) {
                var c = o.item(i);
                if (c.title != '' && c.title != null) {
                    for (var key in i18nObj) {
                        c.title = c.title.replace(key, i18nObj[key]);
                    }
                }
                if (c.alt != '' && c.alt != null) {
                    for (var key in i18nObj) {
                        c.alt = c.alt.replace(key, i18nObj[key]);
                    }
                }
                if (c.nodeType == 3) {
                    for (var key in i18nObj) {
                        c.nodeValue = c.nodeValue.replace(key, i18nObj[key]);
                    }
                } else {
                    zh_i18n(c, i18nObj);
                }
            }
        }

        // 渲染表格
        table.render($.extend({
            url: site_url + '/' + lang + '/' + module + '/' + controller + '/' + action + '.html{if $smarty.server.QUERY_STRING}?{$smarty.server.QUERY_STRING|modifier:htmlentities}{/if}', done: function (res, curr, count) {
                if ($('.layui-laypage').length && lang !== 'zh-CN') {
                    zh_i18n($('.layui-laypage')[0], { '首页': '{$localize.first_page}', '尾页': '{$localize.last_page}' });
                    zh_i18n($('.layui-laypage .layui-laypage-skip')[0], { '页': '', '到第': '{$localize.page_num}', '确定': '{$localize.jump}' });
                    zh_i18n($('.layui-laypage .layui-laypage-count')[0], { '共': '{$localize.total}', '条': '' });
                    zh_i18n($('.layui-laypage .layui-laypage-limits')[0], { '条/页': '/{$localize.per_page|modifier:strtolower}' });
                }
                if ($('.layui-table-tool-self').length && lang !== 'zh-CN') {
                    zh_i18n($('.layui-table-tool-self')[0], { '筛选列': '{$localize.filter_column}', '导出': '{$localize.export}', '打印': '{$localize.print}' });
                }
            }
        }, render));

        // 头工具栏事件
        table.on('toolbar(dataTable)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            var data = checkStatus.data;

            // 头工具栏批量删除
            if (obj.event === 'delAll' || obj.event.match(/^delAll_/)) {
                if (data.length === 0) {
                    return layer.msg('{$localize.choice_row}');
                }
                layer.confirm('{$localize.delall_confirm}', { icon: 3, title: '{$localize.delall}', btn: ['{$localize.ok}', '{$localize.cancel}'] }, function (index) {
                    var ids = [];
                    data.forEach(function (elem) {
                        ids.push(elem.id);
                    });
                    $.post(site_url + '/' + lang + '/' + module + '/' + controller + '/delete' + (obj.event === 'delAll' ? '' : obj.event.slice(6)) + '.html', { id: ids }, function (res) {
                        if (res.code) return layer.msg(res.msg, { icon: 2 });
                        layer.msg(res.msg);
                        table.reload(obj.config.id);
                    }, 'json');
                });
            }

            // 彻底删除
            if (obj.event === 'destroyAll') {
                if (data.length === 0) {
                    return layer.msg('{$localize.choice_row}');
                }
                layer.confirm('{$localize.destroy_all_confirm}', { icon: 3, title: '{$localize.destroy_all}', btn: ['{$localize.ok}', '{$localize.cancel}'] }, function (index) {
                    var ids = [];
                    data.forEach(function (elem) {
                        ids.push(elem.id);
                    });
                    $.post(site_url + '/' + lang + '/' + module + '/' + controller + '/destroy.html', { id: ids }, function (res) {
                        if (res.code) return layer.msg(res.msg, { icon: 2 });
                        layer.msg(res.msg);
                        table.reload(obj.config.id);
                    }, 'json');
                });
            }

            // 还原
            if (obj.event === 'restoreAll') {
                if (data.length === 0) {
                    return layer.msg('{$localize.choice_row}');
                }
                layer.confirm('{$localize.restore_all_confirm}', { icon: 3, title: '{$localize.restore_all}', btn: ['{$localize.ok}', '{$localize.cancel}'] }, function (index) {
                    var ids = [];
                    data.forEach(function (elem) {
                        ids.push(elem.id);
                    });
                    $.post(site_url + '/' + lang + '/' + module + '/' + controller + '/restore.html', { id: ids }, function (res) {
                        if (res.code) return layer.msg(res.msg, { icon: 2 });
                        layer.msg(res.msg);
                        table.reload(obj.config.id);
                    }, 'json');
                });
            }

            // 待审
            if (obj.event === 'pending') {
                if (data.length === 0) {
                    return layer.msg('{$localize.choice_row}');
                }
                layer.confirm('{$localize.pending_all_confirm}', { icon: 3, title: '{$localize.pending_all}', btn: ['{$localize.ok}', '{$localize.cancel}'] }, function (index) {
                    var ids = [];
                    data.forEach(function (elem) {
                        ids.push(elem.id);
                    });
                    $.post(site_url + '/' + lang + '/' + module + '/' + controller + '/pending.html', { id: ids }, function (res) {
                        if (res.code) return layer.msg(res.msg, { icon: 2 });
                        layer.msg(res.msg);
                        table.reload(obj.config.id);
                    }, 'json');
                });
            }

            // 审核通过
            if (obj.event === 'passed') {
                if (data.length === 0) {
                    return layer.msg('{$localize.choice_row}');
                }
                layer.confirm('{$localize.passed_all_confirm}', { icon: 3, title: '{$localize.passed_all}', btn: ['{$localize.ok}', '{$localize.cancel}'] }, function (index) {
                    var ids = [];
                    data.forEach(function (elem) {
                        ids.push(elem.id);
                    });
                    $.post(site_url + '/' + lang + '/' + module + '/' + controller + '/passed.html', { id: ids }, function (res) {
                        if (res.code) return layer.msg(res.msg, { icon: 2 });
                        layer.msg(res.msg);
                        table.reload(obj.config.id);
                    }, 'json');
                });
            }

            // 垃圾评论
            if (obj.event === 'spam') {
                if (data.length === 0) {
                    return layer.msg('{$localize.choice_row}');
                }
                layer.confirm('{$localize.spam_all_confirm}', { icon: 3, title: '{$localize.spam}', btn: ['{$localize.ok}', '{$localize.cancel}'] }, function (index) {
                    var ids = [];
                    data.forEach(function (elem) {
                        ids.push(elem.id);
                    });
                    $.post(site_url + '/' + lang + '/' + module + '/' + controller + '/spam.html', { id: ids }, function (res) {
                        if (res.code) return layer.msg(res.msg, { icon: 2 });
                        layer.msg(res.msg);
                        table.reload(obj.config.id);
                    }, 'json');
                });
            }

            // 头工具栏添加
            if (obj.event === 'add' || obj.event.match(/^add_/)) {
                layer.open({
                    type: 2,
                    maxmin: true,
                    title: '{$localize.add}',
                    shadeClose: true,
                    shade: 0.3,
                    area: [area_width() + 'px', area_height() + 'px'],
                    content: site_url + '/' + lang + '/' + module + '/' + controller + '/' + (obj.event === 'add' ? 'create' : obj.event) + '.html',
                });
            }

            if (obj.event === 'add2') {
                window.location.href = site_url + '/' + lang + '/' + module + '/' + controller + '/create.html';
            }

            if (obj.event === 'upload') {
                if ($('#upload-drag').length) {
                    layer.open({
                        type: 1,
                        title: '{$localize.upload}',
                        shadeClose: true,
                        area: ["280px", "360px"],
                        content: $('#upload-drag'),
                    });
                }
            }

            // 头工具栏刷新
            if (obj.event === 'refresh') {
                table.reload(obj.config.id);
            }

            // 头工具栏计数孤立文件
            if (obj.event === 'calc') {
                layer.confirm('{$localize.calc_file_confirm}', { icon: 3, title: '{$localize.calc_file}', btn: ['{$localize.ok}', '{$localize.cancel}'] }, function (index) {
                    layer.close(index);
                    layer.load(2);
                    $.post(site_url + '/' + lang + '/' + module + '/' + controller + '/calc.html', { calc: 1 }, function (res) {
                        layer.closeAll('loading');
                        if (res.code) return layer.msg(res.msg, { icon: 2 });
                        layer.alert(res.msg, { title: '{$localize.info}', icon: 1, btn: ['{$localize.ok}'] }, function (index) {
                            layer.close(index);
                        });
                        table.reload(obj.config.id);
                    }, 'json');
                });
            }

        });

        // 监听行工具事件
        table.on('tool(dataTable)', function (obj) {
            var data = obj.data;

            // 行工具删除行
            if (obj.event === 'del' || obj.event.match(/^delete_/)) {
                layer.confirm('{$localize.del_row_confirm}', { icon: 3, title: '{$localize.del_row}', btn: ['{$localize.ok}', '{$localize.cancel}'] }, function (index) {
                    layer.close(index);
                    $.post(site_url + '/' + lang + '/' + module + '/' + controller + '/' + (obj.event === 'del' ? 'delete' : obj.event) + '.html', { id: data.id }, function (res) {
                        if (res.code) return layer.msg(res.msg, { icon: 2 });
                        obj.del();
                        layer.msg(res.msg);
                    }, 'json');
                });
            }

            // 同时删除后代
            else if (obj.event === 'del2') {
                layer.confirm('{$localize.del_rows_confirm}', { icon: 3, title: '{$localize.del_row}', btn: ['{$localize.ok}', '{$localize.cancel}'] }, function (index) {
                    layer.close(index);
                    $.post(site_url + '/' + lang + '/' + module + '/' + controller + '/delete.html', { id: data.id }, function (res) {
                        if (res.code) return layer.msg(res.msg, { icon: 2 });
                        table.reload(render.elem.replace(/#/, ''));
                        layer.msg(res.msg);
                    }, 'json');
                });
            }

            // 彻底删除
            else if (obj.event === 'destroy') {
                layer.confirm('{$localize.del_row_confirm}', { icon: 3, title: '{$localize.del_row}', btn: ['{$localize.ok}', '{$localize.cancel}'] }, function (index) {
                    layer.close(index);
                    $.post(site_url + '/' + lang + '/' + module + '/' + controller + '/destroy.html', { id: data.id }, function (res) {
                        if (res.code) return layer.msg(res.msg, { icon: 2 });
                        obj.del();
                        layer.msg(res.msg);
                    }, 'json');
                });
            }

            // 还原
            else if (obj.event === 'restore') {
                layer.confirm('{$localize.restore_row_confirm}', { icon: 3, title: '{$localize.restore_row}', btn: ['{$localize.ok}', '{$localize.cancel}'] }, function (index) {
                    layer.close(index);
                    $.post(site_url + '/' + lang + '/' + module + '/' + controller + '/restore.html', { id: data.id }, function (res) {
                        if (res.code) return layer.msg(res.msg, { icon: 2 });
                        table.reload(render.elem.replace(/#/, ''));
                        layer.msg(res.msg);
                    }, 'json');
                });
            }

            // 行工具当前添加
            else if (obj.event === 'add' || obj.event.match(/^add_/)) {
                layer.open({
                    type: 2,
                    maxmin: true,
                    title: '{$localize.add}',
                    shadeClose: true,
                    shade: 0.3,
                    area: [area_width() + 'px', area_height() + 'px'],
                    content: site_url + '/' + lang + '/' + module + '/' + controller + '/' + (obj.event === 'add' ? 'create' : obj.event) + '.html?id=' + data.id,
                });
            }

            else if (obj.event === 'replay') {
                layer.open({
                    type: 2,
                    maxmin: true,
                    title: '{$localize.reply}',
                    shadeClose: true,
                    shade: 0.3,
                    area: [area_width() + 'px', area_height() + 'px'],
                    content: site_url + '/' + lang + '/' + module + '/' + controller + '/replay.html?id=' + data.id,
                });
            }

            // 行工具编辑行
            else if (obj.event === 'edit' || obj.event.match(/^edit_/)) {
                layer.open({
                    type: 2,
                    maxmin: true,
                    title: '{$localize.edit}',
                    shadeClose: true,
                    shade: 0.3,
                    area: [area_width() + 'px', area_height() + 'px'],
                    content: site_url + '/' + lang + '/' + module + '/' + controller + '/' + (obj.event === 'edit' ? 'edit' : obj.event) + '/' + data.id + '.html',
                });
            }

            else if (obj.event === 'edit2') {
                window.location.href = site_url + '/' + lang + '/' + module + '/' + controller + '/edit/' + data.id + '.html';
            }

            // 显示信息
            else if (obj.event === 'show' || obj.event.match(/^show_/)) {
                layer.open({
                    type: 2,
                    maxmin: true,
                    title: '{$localize.info}',
                    shadeClose: true,
                    shade: 0.3,
                    area: [area_width() + 'px', area_height() + 'px'],
                    content: site_url + '/' + lang + '/' + module + '/' + controller + '/' + obj.event + '/' + data.id + '.html',
                });
            }

            // 按钮事件
            else if (obj.event === 'btn' || obj.event.match(/^button_/)) {
                $.post(site_url + '/' + lang + '/' + module + '/' + controller + '/' + (obj.event === 'btn' ? 'button' : obj.event) + '.html', { id: data.id }, function (res) {
                    if (res.code) return layer.msg(res.msg, { icon: 2 });
                    layer.msg(res.msg, { icon: 1 });
                    table.reload(render.elem.replace(/#/, ''));
                }, 'json');
            }

            else if (obj.event === 'path') {
                layer.prompt({
                    formType: 2, //支持0（文本）默认1（密码）2（多行文本）
                    title: '{$localize.path}', //标题
                    value: data.path,
                }, function (value, index) {
                    layer.close(index);
                });
            }

            // 行工具单元格事件
            else if (['avatar', 'cover', 'preview'].indexOf(obj.event) !== -1) {
                obj.data[obj.event].match(/<img[^>]*src=["\'][^"\']+["\'][^>]*>/im) && layer.open({
                    type: 1,
                    title: '{$localize.preview}',
                    shadeClose: true,
                    shade: 0.3,
                    area: ['340px', '260px'],
                    content: obj.data[obj.event].replace(/\sstyle=["\'][^"\']*["\']/, ' style="width:320px;height:200px;margin-left:10px;margin-top:8px;"')
                });
            }

            else if (obj.event === 'name') {
                layer.prompt({
                    formType: 0, //支持0（文本）默认1（密码）2（多行文本）
                    title: '{$localize.name}', //标题
                    value: data.name,
                }, function (value, index) {
                    $.post(site_url + '/' + lang + '/' + module + '/' + controller + '/modify.html', { id: data.id, field: 'name', value: value }, function (res) {
                        if (res.code) return layer.msg(res.msg, { icon: 2 });
                        layer.close(index);
                        // 同步更新缓存对应的值
                        obj.update({
                            name: value
                        });
                        layer.msg(res.msg, { icon: 1 });
                        table.reload(render.elem.replace(/#/, ''));
                    }, 'json');
                });
            }

            else if (obj.event === 'rename') {
                if (data.status == 0) return layer.alert('{$localize.can_not_calc_status}', { title: '{$localize.info}', icon: 2, btn: ['{$localize.ok}'] });
                layer.prompt({
                    formType: 0, //支持0（文本）默认1（密码）2（多行文本）
                    title: '{$localize.rename}', //标题
                    value: data.name,
                    maxlength: 255
                }, function (value, index) {
                    $.post(site_url + '/' + lang + '/' + module + '/' + controller + '/rename.html', { id: data.id, field: 'name', value: value }, function (res) {
                        if (res.code) return layer.msg(res.msg, { icon: 2 });
                        layer.close(index);
                        // 同步更新缓存对应的值
                        obj.update({
                            name: value
                        });
                        layer.msg(res.msg, { icon: 1 });
                        table.reload(render.elem.replace(/#/, ''));
                    }, 'json');
                });
            }

            else if (obj.event === 'title') {
                layer.prompt({
                    formType: 2, //支持0（文本）默认1（密码）2（多行文本）
                    title: '{$localize.title}', //标题
                    value: data.title,
                }, function (value, index) {
                    $.post(site_url + '/' + lang + '/' + module + '/' + controller + '/modify.html', { id: data.id, field: 'title', value: value }, function (res) {
                        if (res.code) return layer.msg(res.msg, { icon: 2 });
                        layer.close(index);
                        // 同步更新缓存对应的值
                        obj.update({
                            title: value
                        });
                        layer.msg(res.msg, { icon: 1 });
                        table.reload(render.elem.replace(/#/, ''));
                    }, 'json');
                });
            }

            else if (obj.event === 'slug') {
                layer.prompt({
                    formType: 2, //支持0（文本）默认1（密码）2（多行文本）
                    title: '{$localize.slug}', //标题
                    value: data.slug,
                }, function (value, index) {
                    $.post(site_url + '/' + lang + '/' + module + '/' + controller + '/modify.html', { id: data.id, field: 'slug', value: value }, function (res) {
                        if (res.code) return layer.msg(res.msg, { icon: 2 });
                        layer.close(index);
                        // 同步更新缓存对应的值
                        obj.update({
                            slug: value
                        });
                        layer.msg(res.msg, { icon: 1 });
                        table.reload(render.elem.replace(/#/, ''));
                    }, 'json');
                });
            }

            else if (obj.event === 'description') {
                layer.prompt({
                    formType: 2, //支持0（文本）默认1（密码）2（多行文本）
                    title: '{$localize.description}', //标题
                    value: data.description,
                }, function (value, index) {
                    $.post(site_url + '/' + lang + '/' + module + '/' + controller + '/modify.html', { id: data.id, field: 'description', value: value }, function (res) {
                        if (res.code) return layer.msg(res.msg, { icon: 2 });
                        layer.close(index);
                        // 同步更新缓存对应的值
                        obj.update({
                            description: value
                        });
                        layer.msg(res.msg, { icon: 1 });
                        table.reload(render.elem.replace(/#/, ''));
                    }, 'json');
                });
            }

            else if (obj.event === 'seo_title') {
                layer.prompt({
                    formType: 2, //支持0（文本）默认1（密码）2（多行文本）
                    title: 'SEO {$localize.title}', //标题
                    value: data.seo_title,
                }, function (value, index) {
                    $.post(site_url + '/' + lang + '/' + module + '/' + controller + '/modify.html', { id: data.id, field: 'seo_title', value: value }, function (res) {
                        if (res.code) return layer.msg(res.msg, { icon: 2 });
                        layer.close(index);
                        // 同步更新缓存对应的值
                        obj.update({
                            seo_title: value
                        });
                        layer.msg(res.msg, { icon: 1 });
                    }, 'json');
                });
            }

            else if (obj.event === 'seo_description') {
                layer.prompt({
                    formType: 2, //支持0（文本）默认1（密码）2（多行文本）
                    title: 'SEO {$localize.description}', //标题
                    value: data.seo_description,
                }, function (value, index) {
                    $.post(site_url + '/' + lang + '/' + module + '/' + controller + '/modify.html', { id: data.id, field: 'seo_description', value: value }, function (res) {
                        if (res.code) return layer.msg(res.msg, { icon: 2 });
                        layer.close(index);
                        // 同步更新缓存对应的值
                        obj.update({
                            seo_description: value
                        });
                        layer.msg(res.msg, { icon: 1 });
                    }, 'json');
                });
            }

            // 行工具详情页
            else if (obj.event === 'read' || obj.event.match(/^(category|tag|page)-read$/)) {
                window.open(site_url + (lang == 'zh-CN' ? '' : '/' + lang) + '/' + (obj.event === 'read' ? '' : obj.event.slice(0, -5) + '/') + (typeof data.slug !== 'undefined' && data.slug ? data.slug : data.id) + '.html', '_blank');
            }

            // 行工具国际化
            else if (obj.event.match(/^(category|tag|article|page)-i18n$/)) {
                if (data.slug === undefined || data.slug === '') return layer.msg('{$localize.i18n_slug_empty}', { icon: 2 });
                window.location.href = site_url + '/' + lang + '/' + module + '/' + controller + '/' + obj.event.split('-')[0] + '/' + data.id + '.html';
            }

            // 行工具国际化帮助
            else if (obj.event.match(/^(category|tag|article|page)-help$/)) {
                layer.open({
                    type: 2,
                    maxmin: true,
                    title: '{$localize.i18n_help}',
                    shadeClose: true,
                    shade: 0.3,
                    area: [area_width() + 'px', area_height() + 'px'],
                    content: site_url + '/' + lang + '/' + module + '/' + controller + '/' + obj.event.split('-')[0] + '/' + obj.event.split('-')[1] + '/' + data.id + '.html',
                });
            }

            // 行工具弹层或跳转
            else if (obj.event) {
                if (obj.event.match(/^redirect_/)) {
                    window.location.href = site_url + '/' + lang + '/' + module + '/' + controller + '/' + obj.event + '.html?id=' + data.id;
                } else {
                    layer.open({
                        type: 2,
                        maxmin: true,
                        title: '{$localize.info}',
                        shadeClose: true,
                        shade: 0.3,
                        area: [area_width() + 'px', area_height() + 'px'],
                        content: site_url + '/' + lang + '/' + module + '/' + controller + '/' + obj.event + '.html?id=' + data.id,
                    });
                }
            }
        });

        // 监听单元格编辑
        table.on('edit(dataTable)', function (obj) {
            var value = obj.value, //得到修改后的值
                data = obj.data, //得到所在行所有键值
                field = obj.field; //得到字段
            $.post(site_url + '/' + lang + '/' + module + '/' + controller + '/modify.html', { id: data.id, field: field, value: util.escape(value) }, function (res) {
                if (res.code) {
                    layer.alert(res.msg, { title: '{$localize.info}', icon: 2, btn: ['{$localize.ok}'] }, function (index) {
                        table.reload(render.elem.replace(/#/, ''));
                        layer.close(index);
                    });
                    return;
                }
                layer.msg(res.msg);
            }, 'json');
        });

        // 日期开始结束
        if ($('input[name="start"]').length) {
            laydate.render({
                elem: 'input[name="start"]',
            });
        }
        if ($('input[name="end"]').length) {
            laydate.render({
                elem: 'input[name="end"]',
            });
        }

        // 列表开关事件
        form.on('switch(status)', function (obj) {
            $.post(site_url + '/' + lang + '/' + module + '/' + controller + '/modify.html', { id: this.value, field: 'status', value: obj.elem.checked ? 0 : 1 }, function (res) {
                if (res.code) {
                    layer.alert(res.msg, { title: '{$localize.info}', icon: 2, btn: ['{$localize.ok}'] }, function (index) {
                        table.reload(render.elem.replace(/#/, ''));
                        layer.close(index);
                    });
                    return;
                }
                layer.msg(res.msg);
            }, 'json');
        });

        form.on('switch(can_comment)', function (obj) {
            $.post(site_url + '/' + lang + '/' + module + '/' + controller + '/modify.html', { id: this.value, field: 'can_comment', value: obj.elem.checked ? 0 : 1 }, function (res) {
                if (res.code) {
                    layer.alert(res.msg, { title: '{$localize.info}', icon: 2, btn: ['{$localize.ok}'] }, function (index) {
                        table.reload(render.elem.replace(/#/, ''));
                        layer.close(index);
                    });
                    return;
                }
                layer.msg(res.msg);
            }, 'json');
        });

        form.on('switch(is_gallery)', function (obj) {
            $.post(site_url + '/' + lang + '/' + module + '/' + controller + '/modify.html', { id: this.value, field: 'is_gallery', value: obj.elem.checked ? 1 : 0 }, function (res) {
                if (res.code) {
                    layer.alert(res.msg, { title: '{$localize.info}', icon: 2, btn: ['{$localize.ok}'] }, function (index) {
                        table.reload(render.elem.replace(/#/, ''));
                        layer.close(index);
                    });
                    return;
                }
                layer.msg(res.msg);
            }, 'json');
        });

        form.on('switch(is_full)', function (obj) {
            $.post(site_url + '/' + lang + '/' + module + '/' + controller + '/modify.html', { id: this.value, field: 'is_full', value: obj.elem.checked ? 1 : 0 }, function (res) {
                if (res.code) {
                    layer.alert(res.msg, { title: '{$localize.info}', icon: 2, btn: ['{$localize.ok}'] }, function (index) {
                        table.reload(render.elem.replace(/#/, ''));
                        layer.close(index);
                    });
                    return;
                }
                layer.msg(res.msg);
            }, 'json');
        });

        form.on('switch(is_nav)', function (obj) {
            $.post(site_url + '/' + lang + '/' + module + '/' + controller + '/modify.html', { id: this.value, field: 'is_nav', value: obj.elem.checked ? 0 : 1 }, function (res) {
                if (res.code) {
                    layer.alert(res.msg, { title: '{$localize.info}', icon: 2, btn: ['{$localize.ok}'] }, function (index) {
                        table.reload(render.elem.replace(/#/, ''));
                        layer.close(index);
                    });
                    return;
                }
                layer.msg(res.msg);
            }, 'json');
        });

        // 监听搜索框事件
        form.on('submit(search)', function (obj) {
            var field = obj.field;
            table.reload(render.elem.replace(/#/, ''), { where: { search: field }, page: { curr: 1 } }); //搜索重载
            return false;
        });

    });

</script>